package jd;

import java.util.Scanner;

public class JingZiQi {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		char[][] qizi = new char[3][3];
		String[] input = new String[3];
		while(scanner.hasNext()){
			for (int i = 0; i < input.length; i++) {
				input[i] = scanner.next();
			}
			for (int i = 0; i < input.length; i++) {
				qizi[i] = input[i].toCharArray();
			}
			judge(qizi);
		}
		scanner.close();
	}
	
	public static void judge(char[][] qizi){
		if(qizi.length != 3 || qizi[0].length != 3){
			System.out.println("x");
			return;
		}
		for(int i = 0; i < qizi.length; i++){
			for (int j = 0; j < qizi[0].length; j++) {
				if(qizi[i][j] != '.' && qizi[i][j] != '0' && qizi[i][j] != 'X'){
					System.out.println("x");
					return;
				}
			}
		}
		int oneCount = 0;
		int twoCount = 0;
		for (int j = 0; j < qizi.length; j++) {
			for (int k = 0; k < qizi.length; k++) {
				if(qizi[j][k] == '0'){
					twoCount++;
				}else if(qizi[j][k] == 'X'){
					oneCount++;
				}
			}
		}
		if(oneCount < twoCount || oneCount - twoCount >= 2){
			System.out.println("x");
			return;
		}
		
		int i = 0;
		i = isWin(qizi);
//		System.out.println("i : " + i);
		if(i > 2){
			System.out.println("x");
			return;
		}
		if(i == 2 && oneCount > twoCount){
			System.out.println("x");
			return;
		}
		if(i == 1 || i == 2){
			System.out.println( (i == 1 ? "1 won" : "2 won"));
			return;
		}
		
		if(twoCount + oneCount == 9){
			System.out.println("Draw");
		}else{
			System.out.println((twoCount == oneCount) ? "1" : "2");
		}
		
		
	}
	
	public static int isWin(char[][] qizi){
		int sum = 0;
		int res = 0;
		int j = 1;
		int i = 0;
		boolean isWon = false;
		for(; i < 3; i++){
			if(qizi[i][0] == 'X'){
				res = 1;
			}else if(qizi[i][0] == '0'){
				res = 2;
			}else{
				res = 0;
			}
			for(j = 1; j < 3; j++){
				if(qizi[i][j] != qizi[i][0]){
					isWon = false;
					break;
				}else{
					isWon = true;
				}
			}
			if(j == 3 && isWon){
				if(sum != 0){
					return 3;
				}else{
					sum = res;
				}
			}
		}
//		System.out.println( "sum : " + sum);
		for(j = 0; j < 3; j++){
			if(qizi[0][j] == 'X'){
				res = 1;
			}else if(qizi[0][j] == '0'){
				res = 2;
			}else{
				res = 0;
			}
			for(i = 1; i < 3; i++){
				if(qizi[i][j] != qizi[0][j]){
					isWon = false;
					break;
				}else{
					isWon = true;
				}
			}
			if(i == 3 && isWon){
				if(sum != 0){
					return 3;
				}else{
					sum = res;
				}
			}
		}
//		System.out.println( "sum jj : " + sum);
		//判断斜角
		if(qizi[0][0] == 'X'){
			res = 1;
		}else if(qizi[0][0] == '0'){
			res = 2;
		}else{
			res = 0;
		}
		for(i = 1; i < 3; i++){
			if(qizi[i][i] != qizi[0][0]){
				isWon = false;
				break;
			}else{
				isWon = true;
			}
		}
		if(isWon){
			if(sum != 0){
				return 3;
			}else{
				sum = res;
			}
		}
		if(qizi[2][2] == 'X'){
			res = 1;
		}else if(qizi[2][2] == '0'){
			res = 2;
		}else{
			res = 0;
		}
		for(i = 1; i >= 0; i--){
			if(qizi[i][i] !=  qizi[2][2]){
				isWon = false;
				break;
			}else{
				isWon = true;
			}
		}
		if(isWon){
			if(sum != 0){
				return 3;
			}else{
				sum = res;
			}
		}
		return sum;
	}
}
